//--------------------Sonic CD HUD Script---------------------//
//--------Scripted by Christian Whitehead 'The Taxman'--------//
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//

// Aliases
// Not all of these are used here in the HUD script, some are just used as a way for other objects to globally transmit values

// Priority
private alias 1 : PRIORITY_ACTIVE

private alias object.value0 : object.timer
private alias object.value1 : object.chickenjockey

event ObjectMain

end event

event ObjectDraw
	switch object.state
	case 0
	if PlayerJumpscared == 1
		object.timer++
		if object.timer >= 70
			
			//you cant win either
			Object[4].Type = TypeName[Blank Object]
			
			Object[10].Type = TypeName[Blank Object]
			Object[11].Type = TypeName[Blank Object]
			Object[12].Type = TypeName[Blank Object]
			Object[13].Type = TypeName[Blank Object]
			Object[14].Type = TypeName[Blank Object]
			Object[15].Type = TypeName[Blank Object]
			Object[16].Type = TypeName[Blank Object]
			Object[17].Type = TypeName[Blank Object]
			Object[18].Type = TypeName[Blank Object]
			Object[19].Type = TypeName[Blank Object]
			Object[20].Type = TypeName[Blank Object]
			Object[21].Type = TypeName[Blank Object]
			Object[22].Type = TypeName[Blank Object]
			Object[23].Type = TypeName[Blank Object]
			Object[24].Type = TypeName[Blank Object]

			Object[25].Type = TypeName[Blank Object]
			Object[26].Type = TypeName[Blank Object]
			Object[27].Type = TypeName[Blank Object]
			Object[28].Type = TypeName[Blank Object]

			StopSfx(SfxName[Freddy1])	
			StopSfx(SfxName[Freddy2])	
			StopSfx(SfxName[Freddy3])	
			StopSfx(SfxName[Scream2])
			StopSfx(SfxName[Stare])
			StopSfx(SfxName[Fear])
			StopSfx(SfxName[Hum])
			StopSfx(SfxName[Fan])
			StopSfx(SfxName[Pots])
			StopSfx(SfxName[Jumpscare])
			StopSfx(SfxName[Fan2])
			StopSfx(SfxName[Fan3])
			StopSfx(SfxName[Breathing])
			StopSfx(SfxName[SpringScream])
			PlayMusic(1)
			object.chickenjockey = 426
			object.state++
			object.timer = 0
		end if
	end if	
	break
	case 1
		object.chickenjockey = 426
		object.timer++
		if object.timer == 50
			object.state++
			object.timer = 0
		end if

		DrawRect(0, 0, screen.xsize, screen.ysize, color7, 0, 0, object.chickenjockey)// 1
	break
	case 2
		DrawRect(0, 0, screen.xsize, screen.ysize, 0, 0, 0, 255)// 1

		DrawSpriteScreenXY(10, screen.xcenter, screen.ycenter)	//body

		object.chickenjockey -= 8

		DrawRect(0, 0, screen.xsize, screen.ysize, color7, 0, 0, object.chickenjockey)// 1

		if object.chickenjockey <= 0
			object.state++
		end if
		

	break
	case 3
		DrawRect(0, 0, screen.xsize, screen.ysize, 0, 0, 0, 255)// 1
		DrawSpriteScreenFX(10, FX_INK,screen.xcenter, screen.ycenter)	//body


		object.timer++
		if object.timer == 200
			
			stage.activeList = BONUS_STAGE
			stage.listPos = 3
			LoadStage()		

			object.timer = 0
		end if
	break
	end switch
	

end event


event ObjectStartup
	
	LoadSpriteSheet("FNAF/Objects.gif")
	
	// Place the HUD object into reserved object slot 4 and initialise its values
	Object[99].Type = TypeName[Death]
	
	// The object should always be run, regardless if it's within camera bounds or not
	Object[99].Priority = PRIORITY_ACTIVE
	
	// Make the HUD draw ontop of all other sprites, too
	Object[99].DrawOrder = 6

	

	// 0-9 - Numbers 0-9
	SpriteFrame(0, 0, 8, 13, 558, 1)
	SpriteFrame(0, 0, 8, 13, 567, 1)
	SpriteFrame(0, 0, 8, 13, 576, 1)
	SpriteFrame(0, 0, 8, 13, 585, 1)
	SpriteFrame(0, 0, 8, 13, 594, 1)
	SpriteFrame(0, 0, 8, 13, 558, 15)
	SpriteFrame(0, 0, 8, 13, 567, 15)
	SpriteFrame(0, 0, 8, 13, 576, 15)
	SpriteFrame(0, 0, 8, 13, 585, 15)
	SpriteFrame(0, 0, 8, 13, 594, 15)

	SpriteFrame(-65, -10, 137, 16, 1, 204)



end event


// ========================
// Editor events
// ========================

event RSDKDraw
	DrawSprite(0)
end event


event RSDKLoad
	LoadSpriteSheet("3D_Test/Objects.gif")
	SpriteFrame(0, 0, 24, 16, 206, 58)

	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
